package src.thread;

public class SyncDemo4 {
        public static void main(String[] args) {
                Foo f=new Foo();
                Thread t1=new Thread(){
                        public void run(){
                          f.methodA();
                        }
                };
                Thread t2=new Thread(){
                        public void run(){
                          f.methodB();
                        }
                };
                t1.start();
                t2.start();
        }
}
class Foo{
        public synchronized  void methodA(){
                Thread t=Thread.currentThread();
                System.out.println(t.getName()+"感君一回顾");
                try {
                        Thread.sleep(3000);
                } catch (InterruptedException e) {
                }
                System.out.println(t.getName()+"思君朝与暮");
        }
        public  synchronized void methodB(){
                Thread t=Thread.currentThread();
                System.out.println(t.getName()+"感君一回顾...");
                try {
                        Thread.sleep(3000);
                } catch (InterruptedException e) {
                }
                System.out.println(t.getName()+"思君朝与暮...");
        }

}
